<template>
  <div class="conter">
    <van-nav-bar title="我的" left-arrow @click-left="$router.back()" />
    <div class="profile" @click="$router.push('/login')">
      <div class="profile_son">
        <img :src="baseurl + user.avatar" alt />
        <div class="profile-center">
          <div class="login">{{ user_id ? user.username : "登录/注册" }}</div>
          <div class="name">
            <span class="iconfont icon-shouji"></span>
            暂时无绑定手机号
          </div>
        </div>
      </div>
      <van-icon name="arrow" />
      <!-- <span class="iconfont iconjiantou1"></span> -->
    </div>
    <van-grid :column-num="3">
      <van-grid-item>
        <div class="money">
          <span>{{ user_id ? user.balance + ".00" : "0.00" }}</span
          >元
        </div>
        <div class="allmy">我的余额</div>
      </van-grid-item>
      <van-grid-item>
        <div class="money">
          <span class="num">{{ user_id ? user.gift_amount : "0" }}</span
          >个
        </div>
        <div class="allmy">我的优惠</div>
      </van-grid-item>
      <van-grid-item>
        <div class="money">
          <span class="min">{{ user_id ? user.point : "0" }}</span
          >分
        </div>
        <div class="allmy">我的积分</div>
      </van-grid-item>
    </van-grid>
    <div class="myheader">
      <van-cell is-link>
        <template #title>
          <van-icon name="description" />
          <span class="custom-title">我的订单</span>
        </template>
      </van-cell>
      <van-cell is-link>
        <template #title>
          <i class="iconfont icon-shangcheng2" />
          <span class="custom-title">积分商城</span>
        </template>
      </van-cell>
      <van-cell is-link>
        <template #title>
          <i class="iconfont icon-huiyuan" />
          <span class="custom-title">饿了么会员卡</span>
        </template>
      </van-cell>
    </div>
    <div class="myheader">
      <van-cell is-link>
        <template #title>
          <i class="iconfont icon-fuwu" />
          <span class="custom-title">服务中心</span>
        </template>
      </van-cell>
      <van-cell is-link>
        <template #title>
          <i class="iconfont icon-elemo" />
          <span class="custom-title">下载饿了么App</span>
        </template>
      </van-cell>
    </div>
  </div>
</template>

<script>
import axios from "@/untils/request.js";
import { userInfo } from "@/api/login.js";
export default {
  data() {
    return {
      user_id: localStorage.getItem("Userid") || "",
      user: {},
      baseurl: axios.defaults.baseURL + "/img/",
    };
  },
  created() {
    if (this.user_id) {
      userInfo({ user_id: this.user_id }).then((res) => {
        console.log(158, res);
        this.user = res.data;
      });
    }
  },
};
</script>

<style lang="less" scoped>
/deep/.van-nav-bar {
  background-color: #3190e8;
  border-bottom: 1px solid #d4d3d3;
  .van-icon {
    color: #fff;
  }
  .van-nav-bar__title {
    color: #fff;
  }
}
.profile {
  background-color: #3190e8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  .profile_son {
    display: flex;
    justify-content: space-between;
    .profile-center {
      margin-left: 10px;
      display: flex;
      flex-direction: column;
      justify-content: space-evenly;
      color: #fff;
      .login {
        font-size: 20px;
      }
      .name {
        font-size: 14px;
      }
    }
    img {
      width: (60 / 360) * 100vw;
      height: (60 / 360) * 100vw;
      border-radius: 50%;
    }
  }
  .van-icon {
    color: #fff;
  }
}
/deep/.van-grid {
  height: 50%;
  .van-grid-item {
    height: 50%;
    .money {
      font-size: 14px;
      span {
        font-size: 28px;
        color: #ff9800;
        font-weight: 700;
      }
      .num {
        color: #ff5e3a;
      }
      .min {
        color: #6ac208;
      }
    }
    .allmy {
      margin-top: 5px;
      font-size: 12px;
    }
  }
}
.myheader {
  margin-top: 10px;
  .icon-shangcheng2 {
    color: red;
    font-size: 16px;
  }
  .icon-huiyuan {
    color: #ffc535;
  }
  .custom-title {
    margin-left: 5px;
  }
  .icon-fuwu {
    color: #4aa5f0;
    font-size: 16px;
  }
  .icon-elemo {
    color: #4aa5f0;
    font-size: 16px;
  }
}
</style>